<?php
$this->Html->addCrumb('Gallery');
?>

<h1 class="pageTitle">Gallery</h1>
<?php echo $this->Html->image('gallery_main.jpg', array("alt"=>'Gallery', "class"=>"right photo", "title"=>"Gallery"))?>

<p>Welcome to our gallery. We hope you enjoy browsing through the albums. </p>

<p>Select a category from which to view photos.</p>


<?php
  if (isset($categories) && !empty($categories)) {
    echo '<ul>';
    $photographers = array();
    foreach ($categories as $category) {
      if(empty($category['Category']['company_id'])) {
        echo '<li>'.$this->Html->link($category['Category']['name'], array('controller' => 'albums', 'action' => 'index', $category['Category']['id']), array("title"=>"View the albums in this category")).' '.$category[0]['AlbumCount'].' Album(s)</li>' ;
      } else {
        array_push($photographers, $category);
      }
    }
    echo '</ul>';

    if(!empty($photographers)){
      echo '<p class="featuredPhotographers">Our Featured Photographers</p>';
      echo '<ul>';
       foreach ($photographers as $photographer) {
        echo '<li>'.$this->Html->link($photographer['Category']['name'], array('controller' => 'albums', 'action' => 'index', $photographer['Category']['id']), array("title"=>"View the albums from this photographer")).' '.$photographer[0]['AlbumCount'].' Album(s)</li>' ;
      }
      echo '</ul>';
    }

  } else {
    echo '<p>No albums are currently available.</p>';
  }

  if (!empty($videos)){
    echo '<p class="featuredVideographers">Videos from our featured Videographers</p>';
    foreach($videos as $video){
      echo '<li>'.$this->Html->link($video['Company']['name'], array('controller' => 'videos', 'action' => 'index', $video['Company']['id']), array("title"=>"View the videos from this videographer")).' '.$video[0]['VideoCount'].' Video(s)</li>' ;
    }
  }

?>